#include "head.h"

/* Usage:  */


bool sql_select(MYSQL *conn, char *sql_statement, sql_t *select_result)
{
    sql_t *select_sql = select_result;
    memset(select_sql, 0, sizeof(select_sql));
    //char *sql = "select * from file where path =file_path and id = user_id";
    
    if(mysql_query(conn, sql_statement)){
        printf("%s\n",mysql_error(conn));
        return false;
    }
    select_sql->result= mysql_store_result(conn);
    select_sql->row = mysql_fetch_row(select_sql->result);
    return true;

}

bool sql_insert(MYSQL *conn, char *sql_statement, sql_t *insert_result){

    sql_t *insert_sql = insert_result;
    memset(insert_sql, 0, sizeof(insert_sql));
    //char *sql = "select * from file where path =file_path and id = user_id";
    if(mysql_query(conn, sql_statement)){
        printf("%s\n",mysql_error(conn));
        return false;
    }
    //select_sql->result= mysql_store_result(conn);
    //select_sql->row = mysql_fetch_row(select_sql->result);
    return true;
}

bool sql_update(MYSQL *conn, char *sql_statement, sql_t *update_result){

    sql_t *update_sql = update_result;
    memset(update_sql, 0, sizeof(update_sql));
    //char *sql = "select * from file where path =file_path and id = user_id";
    if(mysql_query(conn, sql_statement)){
        printf("%s\n",mysql_error(conn));
        return false;
    }
    //select_sql->result= mysql_store_result(conn);
    //select_sql->row = mysql_fetch_row(select_sql->result);
    return true;
}

